package mulegame;
/**
 * Sets games difficulty and number of players
 * 
 * @author AREA 29
 *
 */

public class GameConfig{
	/**
	 * stores different difficulties 
	 * 
	 * @author AREA 29
	 */
    public enum Difficulty {
        BEGINNER (0), 
        STANDARD (1),
        TOURNAMENT (2);
        
        int id;
        
        Difficulty(int id){
            this.id = id;    
        }
        public String toString(){
            String ret = "";
            switch(id){
            case 0:
                ret += "Beginner : ";
                break;
            case 1:
                ret += "Standard : ";
                break;
            case 2:
                ret += "Tournament : ";
                break;
            default:
                Logger.println("Unkown Difficulty id");
                break;
            }
            return ret + Integer.toString(id);   
        }
    }
    private int[] roundFoodRequirement = {0,3,3,3,3,4,4,4,4,5,5,5,5}; 
    private int[] roundGambleBonus = {0,50,50,50,100,100,100,100,150,150,150,150,200};
    private int[] roundRandomEventFactor = {25,25,25,50,50,50,50,75,75,75,75,100};
    private Difficulty difficulty;
    private int numPlayers;
    /**
     * Demo system prints out "GameConfig created"
     */
    public GameConfig(){
//        Logger.println("GameConfig created");   
    }
    
    public GameConfig(String[] definition){
        String[] args;
        for(String line : definition){
            args = line.split("\\s:\\s");
            if(args[0].equals("Num Players")){
                setNumPlayers(Integer.parseInt(args[1]));
            }
            if(args[0].equals("Difficulty")){
                switch(Integer.parseInt(args[2])){
                case 0:
                    setDifficulty(Difficulty.BEGINNER);
                    break;
                case 1:
                    setDifficulty(Difficulty.STANDARD);
                    break;
                case 2:
                    setDifficulty(Difficulty.TOURNAMENT);
                    break;
                default:
                    Logger.println("Unknown difficulty id");
                    break;
                }
            }
        }
           
    }
    /**
     * sets internal difficulty level based on parameter
     * 
     * @param diff difficulty of the level
     */
    public void setDifficulty(Difficulty diff){
        difficulty = diff;   
    }
    
    public Difficulty getDifficulty(){
    	return difficulty;
    }
    /**
     * sets internal number of players based on parameter
     * 
     * @param num number of players
     */
    public void setNumPlayers(int num){
        numPlayers = num;   
    }
    /**
     * returns number of players 
     * 
     * @return numPlayers number of players
     */
    public int getNumPlayers(){
        return numPlayers;   
    }
    /**
     * return food requirement based on what round it is
     * @param round index in array of what round it is
     * @return roundFoodRequirement[round] food required for that round
     */
    public int getRoundFood(int round){
        return roundFoodRequirement[round];   
    }
    /**
     * returns round bonus based on what round it is 
     * @param round index in array of what round it is
     * @return roundGambleBonus the bonus from gambling that round
     */
    public int getRoundBonus(int round){
        return roundGambleBonus[round];   
    }
    /**
     * returns random even factor based on what round it is 
     * @param round index in array of what round it is
     * @return roundRandomEventFactor the factor used in getting random event that round
     */
    public int getRoundRandomEventFactor(int round){
        return roundRandomEventFactor[round];   
    }
    
    public String toString(){
        String ret = "";
        ret += "Num Players : " + Integer.toString(numPlayers) + "\n";
        ret += "Difficulty : " + difficulty.toString() + "\n";
        return ret;
    }
}
